home *** CD-ROM | disk | FTP | other *** search
/ Basic Instinct 2 Press Kit / Basic Instinct 2 Press Kit.iso / pc / main.dxr / FlashPaper_1_BIProdNotes.swf / scripts / __Packages / FPUI / DataProvider.as < prev    next >
Encoding:
Text File  |  2006-03-15  |  1.6 KB  |  76 lines

  1. class FPUI.DataProvider
  2. {
  3.    var m_items = null;
  4.    var m_views = null;
  5.    var m_uniqueID = 0;
  6.    function DataProvider()
  7.    {
  8.       this.m_items = new Array();
  9.       this.m_views = new Array();
  10.    }
  11.    function addView(viewRef)
  12.    {
  13.       this.m_views.push(viewRef);
  14.       viewRef.dataViewModelChanged();
  15.    }
  16.    function removeView(viewRef)
  17.    {
  18.       var _loc1_ = this;
  19.       var _loc2_ = viewRef;
  20.       for(var _loc3_ in _loc1_.m_views)
  21.       {
  22.          if(_loc1_.m_views[_loc3_] == _loc2_)
  23.          {
  24.             _loc1_.m_views[_loc3_] = null;
  25.          }
  26.       }
  27.       _loc2_.dataViewModelChanged();
  28.    }
  29.    function addItemAt(index, value)
  30.    {
  31.       var _loc1_ = this;
  32.       var _loc2_ = index;
  33.       if(_loc2_ < _loc1_.getLength())
  34.       {
  35.          _loc1_.m_items.splice(_loc2_,0,false);
  36.       }
  37.       _loc1_.m_items[_loc2_] = value;
  38.       _loc1_.updateViews();
  39.    }
  40.    function removeItemsAt(index, count)
  41.    {
  42.       if(count > 0)
  43.       {
  44.          this.m_items.splice(index,count);
  45.       }
  46.       this.updateViews();
  47.    }
  48.    function removeAll()
  49.    {
  50.       this.m_items = new Array();
  51.       this.updateViews();
  52.    }
  53.    function getLength()
  54.    {
  55.       return this.m_items.length;
  56.    }
  57.    function getItemAt(index)
  58.    {
  59.       return this.m_items[index];
  60.    }
  61.    function updateViews()
  62.    {
  63.       var _loc3_ = this;
  64.       var _loc1_ = 0;
  65.       while(_loc1_ < _loc3_.m_views.length)
  66.       {
  67.          var _loc2_ = _loc3_.m_views[_loc1_];
  68.          if(_loc2_)
  69.          {
  70.             _loc2_.dataViewModelChanged();
  71.          }
  72.          _loc1_ = _loc1_ + 1;
  73.       }
  74.    }
  75. }
  76.